<?php
namespace Home\Controller;
use Think\Controller;
use Think\Page;
class AssetController extends CommonController {
	//注册积分明细
	public  function register(){
		$this -> assign('title','注册积分明细');
		$mod = M('account_log');
		$endtime = strtotime(I('get.end'));
		$starttime = strtotime(I('get.start'));
			if(empty(I('get.jtype'))||I('get.jtype')==1){
				
			}else{
				$type = I('get.jtype');
				$data['change_type'] = array('eq',$type);
			}
			$data['user_id'] = $_SESSION['users']['user_id'];
			$data['user_money2'] = array('neq',0);
				if(!empty($endtime)&&!empty($starttime)){	
					//WHERE条件查询数组																	
						$data['change_time'] = array('egt',$starttime);
					//设置分页的配置
			 			$page = new Page($mod -> where($data)->where('change_time<='.$endtime)->count(),8);			 			
			 			$page->setConfig('prev','上一页');
			 			$page->setConfig('next','下一页');			
			 		
						//分页链接
						$url = $page->show();		
				
						$register = $mod -> field('user_money2,change_time,change_type,change_desc')->where($data)->where('change_time<='.$endtime)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();
						$this -> assign('url',$url);	
				}elseif(empty($endtime)&&!empty($starttime)){													
							$data['change_time'] = array('egt',$starttime);
							//设置分页的配置
				 			$page = new Page($mod -> where($data)->count(),8);
							$register = $mod -> field('user_money2,change_time,change_type,change_desc')->where($data)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();	
										 		
				 			$page->setConfig('prev','上一页');
				 			$page->setConfig('next','下一页');			 		
							//分页链接
							$url = $page->show();
				}elseif(!empty($endtime)&&empty($starttime)){	
							//设置分页的配置
				 			$page = new Page($mod -> where($data)->count(),8);											
							$data['change_time'] = array('elt',$endtime);
							$register = $mod -> field('user_money2,change_time,change_type,change_desc')->where($data)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();						
									 		
				 			$page->setConfig('prev','上一页');
				 			$page->setConfig('next','下一页');			 		
							//分页链接
							$url = $page->show();
				}else{										
							//设置分页的配置
				 			$page = new Page($mod -> where($data)->count(),8);			 		
				 			$page->setConfig('prev','上一页');
				 			$page->setConfig('next','下一页');	
							$register = $mod -> field('user_money2,change_time,change_type,change_desc')->where($data)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();
									 		
							//分页链接
							$url = $page->show();
				}											
						
						
			
		$this -> assign('register',$register);		
		$this -> assign('url',$url);		
		$this -> display('');
	}


	
	//现金积分明细
	public function cash(){
		$this -> assign('title','现金积分明细');
		$mod = M('account_log');
		$id = $_SESSION['users']['user_id'];
		//各项奖金项目
		$usermod = M('users');
		$sumMoney = $usermod ->field('pay_points2,pay_points4,pay_points3,pay_points1,pay_points5')-> where('user_id = "%s"',$id) ->find(); 
		$sum = $sumMoney['pay_points2']+$sumMoney['pay_points4']+$sumMoney['pay_points3']+$sumMoney['pay_points1']+$sumMoney['pay_points5'];
		$this -> assign('sumMoney',$sumMoney);
		$this -> assign('sum',$sum);
		//提交的查找时间
		$endtime = strtotime(I('get.end'));
		$starttime = strtotime(I('get.start'));		
		//判断奖金类型
		if(I('get.cashtype')==1){
			$data['pay_points2'] = array('neq',0);
		}elseif(I('get.cashtype')==2){
			$data['pay_points4'] = array('neq',0);
		}elseif(I('get.cashtype')==3){
			$data['pay_points3'] = array('neq',0);
		}elseif(I('get.cashtype')==4){
			$data['pay_points1'] = array('neq',0);
		}elseif(I('get.cashtype')==5){
			$data['pay_points5'] = array('neq',0);
		}
		$this -> assign('type',I('get.cashtype'));
		//查询条件
		$data['user_id'] = $id;
		$data['change_type'] = array('eq',99);
		$data['user_money1'] = array('neq',0);
		if(!empty($endtime)&&!empty($starttime)){		
					//WHERE条件查询数组																	
						$data['change_time'] = array('egt',$starttime);
					//设置分页的配置
			 			$page = new Page($mod -> where($data)->where('change_time<='.$endtime)->count(),10);
			 			 			
			 			$page->setConfig('prev','上一页');
			 			$page->setConfig('next','下一页');			 		
						//分页链接
						$url = $page->show();				
						$cash = $mod -> field('pay_points1,pay_points2,pay_points3,pay_points4,pay_points5,change_time,change_desc')->where($data)->where('change_time<='.$endtime)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();
						$this -> assign('url',$url);	
				}elseif(empty($endtime)&&!empty($starttime)){																				
							$data['change_time'] = array('egt',$starttime);	
							//设置分页的配置
			 				$page = new Page($mod -> where($data)->count(),10);		
							$cash = $mod -> field('pay_points1,pay_points2,pay_points3,pay_points4,pay_points5,change_time,change_desc')->where($data)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();
							//分页链接
						$url = $page->show();
				}elseif(!empty($endtime)&&empty($starttime)){											
							$data['change_time'] = array('elt',$endtime);
							//设置分页的配置
			 				$page = new Page($mod -> where($data)->count(),10);		
							$cash = $mod -> field('pay_points1,pay_points2,pay_points3,pay_points4,pay_points5,change_time,change_desc')->where($data)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();						
							$url = $page->show();
				}else{		
						//设置分页的配置
			 			$page = new Page($mod -> where($data)->count(),10);										
						$cash = $mod -> field('pay_points1,pay_points2,pay_points3,pay_points4,pay_points5,change_time,change_desc')->where($data)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();
				// echo M()->_SQL();
				}
				
					//设置分页的配置			 		
			 			$page->setConfig('prev','上一页');
			 			$page->setConfig('next','下一页');			 		
						//分页链接
						$url = $page->show();	
			//$cash = $mod -> field('pay_points1,pay_points2,pay_points3,pay_points4,pay_points5,change_time,change_desc')->where($data)->limit($page->firstRow,$page->listRows)->select();
		// dump($cash);
		$this -> assign('cash',$cash);
		$this -> assign('url',$url);
		$this -> assign('page_num',$mod -> where($data)->count());
		$this -> display('');
	}
	//认购积分明细
	public function scription(){
		$this -> assign('title','认购积分明细');
		$mod = M('account_log');
		$id = $_SESSION['users']['user_id'];
		//提交的查找时间
		$endtime = strtotime(I('get.end'));
		$starttime = strtotime(I('get.start'));			
		$data['user_id'] = $id;	
		$data['user_money3'] = array('neq',0);	
		if(!empty($endtime)&&!empty($starttime)){	
					//WHERE条件查询数组																	
						$data['change_time'] = array('egt',$starttime);
					//设置分页的配置
			 			$page = new Page($mod -> where($data)->where('change_time<='.$endtime)->count(),6);			 			
			 			$page->setConfig('prev','上一页');
			 			$page->setConfig('next','下一页');			 		
						//分页链接
						$url = $page->show();				
						$scription = $mod -> field('change_time,change_desc,user_money3')->where($data)->where('change_time<='.$endtime)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();
						$this -> assign('url',$url);	
				}elseif(empty($endtime)&&!empty($starttime)){													
							$data['change_time'] = array('egt',$starttime);
							$scription = $mod -> field('change_time,change_desc,user_money3')->where($data)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();						
				}elseif(!empty($endtime)&&empty($starttime)){											
							$data['change_time'] = array('elt',$endtime);	
							$scription = $mod -> field('change_time,change_desc,user_money3')->where($data)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();					
				}else{										
						$scription = $mod -> field('change_time,change_desc,user_money3')->where($data)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();
				}				
					//设置分页的配置
			 			$page = new Page($mod -> where($data)->count(),6);			 		
			 			$page->setConfig('prev','上一页');
			 			$page->setConfig('next','下一页');			 		
						//分页链接
						$url = $page->show();	
		$scription = $mod -> field('change_time,change_desc,user_money3')->where($data)->limit($page->firstRow,$page->listRows)->select();
		
		$this -> assign('page_num',$mod -> where($data)->count());
		$this -> assign('url',$url);
		$this -> assign('scription',$scription);
		$this -> display('');
	}

	//E积分明细
	public function epoint(){
		$this -> assign('title','E积分明细');
		$mod = M('account_log');
		$id = $_SESSION['users']['user_id'];
			//设置分页的配置
			 			$page = new Page($mod ->where('(user_money1 != 0 or user_money4 != 0 or option_num != 0) and change_type = 60 and user_id='.$id)->count(),6);			 		
			 			$page->setConfig('prev','上一页');
			 			$page->setConfig('next','下一页');			 		
						//分页链接
						$url = $page->show();
			
		$epoint = $mod -> field('change_time,change_desc,user_money3,user_money4,user_money1,option_num')->where('(user_money1 != 0 or user_money4 != 0 or option_num != 0) and change_type = 60 and user_id='.$id)->order('change_time desc')->limit($page->firstRow,$page->listRows)->select();
		$this -> assign('epoint',$epoint);
		$this -> assign('page_num',$mod ->where('(user_money1 != 0 or user_money4 != 0 or option_num != 0) and change_type = 60 and user_id='.$id)->count());
		$this -> assign('url',$url);
		$this -> display('');
	}

	//上市积分明细
	public function stock(){
		$this -> assign('title','上市积分明细');		

		$this -> display('');
	}



}